package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * sky-take-out
 * com.sky.mapper <BR>
 * C端购物车持久层接口
 * @author Ablecisi
 * @version 1.0
 * 2025/4/10
 * 15:25
 */
@Mapper
public interface ShoppingCartMapper {

    /**
     * 查询购物车
     * @param shoppingCart 购物车对象
     * @return 购物车列表
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 添加购物车
     * @param shoppingCart 购物车对象
     */
    void updateCart(ShoppingCart shoppingCart);

    /**
     * 更新购物车
     * @param shoppingCart 购物车对象
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param shoppingCart 购物车对象
     */
    @Delete("DELETE FROM sky_take_out.shopping_cart WHERE user_id = #{userId}")
    void clean(ShoppingCart shoppingCart);

    /**
     * 删除对应的购物车记录
     * @param cartId 购物车id
     */
    @Delete("DELETE FROM sky_take_out.shopping_cart WHERE id = #{cartId}")
    void deleteById(Long cartId);

    /**
     * 批量插入购物车数据
     *
     * @param shoppingCartList 购物车列表
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
